package com.gradle.service.impl;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gradle.annotation.Pay;
import com.gradle.mapper.ChannelMapper;
import com.gradle.mapper.GoodsMapper;
import com.gradle.pojo.Channel;
import com.gradle.pojo.Goods;
import com.gradle.service.Strategy;

/**
 * 中国工商银行
 * @author Administrator
 *
 */
@Service
@Pay(channelId=2)
public class ICBCBank implements Strategy{

	@Autowired
	private ChannelMapper channelMapper;
	
	@Autowired
	private GoodsMapper goodsMapper;
	
	@Override
	public BigDecimal getPrice(int channelId, int goodsId) {
		Channel channel = this.channelMapper.selectByPrimaryKey(channelId);
		Goods goods = this.goodsMapper.selectByPrimaryKey(goodsId);
		return channel.getDisCount().multiply(new BigDecimal(goods.getPrice()));
	}

}
